package com.cloudptt.api.product.func.sys;

public class SysStateInfo 
{
	public static final int SysState_Begin                        		= 0;
	public static final int SysState_SvrStopState                 		= SysState_Begin + 1;
	public static final int SysState_SvrStartState                 		= SysState_Begin + 2;
//	public static final int SysState_HttpGetingState           			= SysState_Begin + 3;
//	public static final int SysState_HttpGetSucState           			= SysState_Begin + 4;
	public static final int SysState_HttpAuthingState           		= SysState_Begin + 5;
	public static final int SysState_HttpAuthSucState           		= SysState_Begin + 6;
	public static final int SysState_SipAuthingState           			= SysState_Begin + 7;
	public static final int SysState_SipAuthSucState           			= SysState_Begin + 8;
	
	public static final int Cause_Begin                        		= 10;
	public static final int Cause_Suc                 		        = Cause_Begin + 1;
	public static final int Cause_Failed                 		    = Cause_Begin + 2;
	public static final int Cause_Timeout                 		    = Cause_Begin + 3;
	public static final int Cause_Input                 		    = Cause_Begin + 4;
	public static final int Cause_Unauthorized                 		= Cause_Begin + 5;
	public static final int Cause_Logout                      		= Cause_Begin + 6;
	public static final int Cause_Relogin                      		= Cause_Begin + 7;
	
	private int state = SysState_SvrStopState;
	private int cause = Cause_Suc;

	public SysStateInfo(int state,int cause)
	{
		this.state = state;
		this.cause = cause;
	}
	
	public int getState() {
		return state;
	}

	public int getCause() {
		return cause;
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer(" SysStateInfo ");
		strBuf.append("state = ").append(state).append(",");
		strBuf.append("cause = ").append(cause).append(".");
		
		return strBuf.toString();
	}

	public String toStrDesc()
	{
		StringBuffer strBuf = new StringBuffer(" SysStateInfo ");
		strBuf.append("state = ").append(stateTag(state)).append(",");
		strBuf.append("cause = ").append(causeTag(cause)).append(".");

		return strBuf.toString();
	}
	
	public static String stateTag(int type) {
		String tag="unknown type = " + type;
		switch (type)
		{
		case SysState_Begin:
			tag = "SysState_Begin";
		break;
		case SysState_SvrStopState:
			tag = "SysState_SvrStopState";
		break;
		case SysState_SvrStartState:
			tag = "SysState_SvrStartState";
			break;
		case SysState_HttpAuthingState:
			tag = "SysState_HttpAuthingState";
		break;
		case SysState_HttpAuthSucState:
			tag = "SysState_HttpAuthSucState";
		break;
			
		case SysState_SipAuthingState:
			tag = "SysState_SipAuthingState";
		break;
		case SysState_SipAuthSucState:
			tag = "SysState_SipAuthSucState";
		break;
		default:
			break;
		}
		return tag;
	}

	public static String causeTag(int cause) {
		String tag="unknown cause = " + cause;
		switch (cause)
		{
			case Cause_Suc:
				tag = "Cause_Suc";
				break;
			case Cause_Failed:
				tag = "Cause_Failed";
				break;
			case Cause_Timeout:
				tag = "Cause_Timeout";
				break;
			case Cause_Input:
				tag = "Cause_Input";
				break;
			case Cause_Unauthorized:
				tag = "Cause_Unauthorized";
				break;
			case Cause_Logout:
				tag = "Cause_Logout";
				break;
			default:
				break;
		}
		return tag;
	}
}
